package com.itheima.sfbx.test;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Strategytest {
    // 将map声明为静态成员变量
    private static Map<String,DiscountStrategyTest> map = new HashMap<>();

    // 静态代码块初始化
    static{
        map.put("normal",new Normal());
        map.put("silver",new Silver());
        map.put("gold",new Gold());
    }

    public static void main(String[] args) {
        while (true){
            System.out.println("请输入会员等级：");
            //从map中获取并调用他们
            Scanner sc =new Scanner(System.in);
            String level = sc.next();
            DiscountStrategyTest strategy = map.get(level);
            System.out.println("请输入价格：");
            double price = sc.nextDouble();
            Double calculate = strategy.calculate(price);
            System.out.println("calculate = " + calculate);
        }
    }
}
